旧Siv3D
Play Siv3D!
Siv3D リファレンス
struct ParamScale
{
float scale;
float unused[3];
};
void setScale(const int scale)
{
ConstantBuffer<ParamScale> cb;
cb->scale = scale;
PostEffect::SetConstant(ShaderStage::Pixel, 1, cb);
}
void Main()
{
Window::Resize(640, 480);
Graphics::SetBackground(Palette::Black);
int scale = 2;
PostEffect::Register(PixelShader(L"scale.hlsl"));
setScale(scale);
const Texture texture(L"Example/Siv3D-kun.png");
while (System::Update())
{
if (Input::KeyUp.clicked)
{
scale = Min(scale + 1, 4);
setScale(scale);
}
else if (Input::KeyDown.clicked)
{
scale = Max(scale - 1, 1);
setScale(scale);
}
texture.draw();
PutText(L"scale = ", scale).from(2, 2);
}
}
Texture2D texture0 : register( t0 );
SamplerState sampler0 : register( s0 );
struct VS_OUTPUT
{
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
cbuffer psConstants1 : register( b1 )
{
float g_scale;
};
float4 PS(VS_OUTPUT input) : SV_Target
{
return texture0.Sample(sampler0, input.tex / g_scale) * input.color;
}